package com.wfg.collection

object TestArray {

  def main(args: Array[String]): Unit = {
    val arr = new Array[Int](10)
    println(arr.length)

    val ints1 = Array(10, 30)
    println(ints1.length)
    val ints = Array.apply(10, 2)
    println(ints.length)
    println(ints1(0))
    println(ints1(1))
    ints1(1) = 12
    println(ints1(1))
    println("================")
    for(i <-ints1.indices){
      println(ints1(i))
    }
    println("================")
    for(elem <- ints1){
      println(elem)
    }
    println("================")
    val iterator = ints1.iterator
    while (iterator.hasNext){
      println(iterator.next())
    }
    println("================")
    arr.foreach(elemt => println(elemt))
    println("================")
    val newArr = arr :+ 10 //  arr.:+(10) add to end
    println(newArr.mkString(", "))
    val newArr2 = 20 +: 10 +: arr :+ 30 // arr.+:(10).+:(20).:+(30)
    println(newArr2.mkString(", "))
  }
}
